package cn.iocoder.yudao.module.call.controller.admin.statistics;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.call.controller.admin.statistics.vo.CallStatisticsChannelRankRespVO;
import cn.iocoder.yudao.module.call.controller.admin.statistics.vo.CallStatisticsRankReqVO;
import cn.iocoder.yudao.module.call.controller.admin.statistics.vo.CallStatisticsRankRespVO;
import cn.iocoder.yudao.module.call.service.statistics.CallStatisticsRankingService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

@Tag(name = "呼叫中心 - 排行榜数据统计与分析")
@RestController
@RequestMapping("/call/statistics-rank")
@Validated
public class CallStatisticsRankController {


    @Resource
    private CallStatisticsRankingService rankingService;

    @GetMapping("/get-call-count-rank")
    @Operation(summary = "获得外呼总量排行榜")
    @PreAuthorize("@ss.hasPermission('call:statistics-rank:query')")
    public CommonResult<List<CallStatisticsRankRespVO>> getCallCountRank(@Valid CallStatisticsRankReqVO rankingReqVO) {
        return success(rankingService.getCallCountRank(rankingReqVO));
    }


    @GetMapping("/get-success-count-rank")
    @Operation(summary = "获得接通数排行榜")
    @PreAuthorize("@ss.hasPermission('call:statistics-rank:query')")
    public CommonResult<List<CallStatisticsRankRespVO>> getSuccessCountRank(@Valid CallStatisticsRankReqVO rankingReqVO) {
        return success(rankingService.getSuccessCountRank(rankingReqVO));
    }

    @GetMapping("/get-call-second-rank")
    @Operation(summary = "获得接通数排行榜")
    @PreAuthorize("@ss.hasPermission('call:statistics-rank:query')")
    public CommonResult<List<CallStatisticsRankRespVO>> getCallSecondRank(@Valid CallStatisticsRankReqVO rankingReqVO) {
        return success(rankingService.getCallSecondRank(rankingReqVO));
    }

    @GetMapping("/get-call-channel-rank")
    @Operation(summary = "获得渠道排行榜")
    @PreAuthorize("@ss.hasPermission('call:statistics-rank:query')")
    public CommonResult<List<CallStatisticsChannelRankRespVO>> getCallChannelRank(@Valid CallStatisticsRankReqVO rankingReqVO) {
        return success(rankingService.getCallChannelRank(rankingReqVO));
    }
}